<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div th:replace="pages/admin/commons/header :: header"></div>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
<style>
    .cen {
        text-align: center !important;
    }
</style>
<body>
<div class="wap-container">
    <nav class="breadcrumb" style="background-color:#fff;padding: 0 24px">
        首页
        <span class="c-gray en">/</span>
        儿童保健
        <span class="c-gray en">/</span>
        化验检测模版
        <a class="btn btn-success radius f-r" href="javascript:location.replace(location.href);"
           style="line-height:1.6em;margin-top:3px" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
    </nav>
    <article class="Hui-admin-content clearfix">
        <div class="wap-container">
            <div class="panel">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                    <legend>化验检测模版</legend>

                    <a style="float: right; margin-right: 5%" href="javascript:;" id="add_record"
                       class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加数据</a>
                    <!--                    <div style="width: 250px;margin-left: 35%" th:if="${result} == null"-->
                    <!--                         class="form-controls col-xs-8 col-sm-9">-->
                    <!--                        <span class="select-box">-->
                    <!--							<select id="sel2" class="select" name="category">-->
                    <!--							</select>-->
                    <!--                        </span>-->
                    <!--                    </div>-->
                </fieldset>

                <div style="display: inline-block; width: 68%; height: 410px; padding: 10px; border: 1px solid #ddd; overflow: auto;margin-left: 15%">

                    <table style="float: right;" class="layui-table">
                        <colgroup>
                            <col width="150">
                            <col width="200">
                            <col>
                        </colgroup>
                        <thead style="text-align: center">
                        <tr>
                            <th class="cen">代码</th>
                            <th class="cen">名称</th>
                            <th class="cen">类别</th>
                            <th class="cen">公用</th>
                            <th class="cen">操作</th>
                        </tr>
                        </thead>
                        <tbody id="nodeInfo">

                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <!--				<td class="va-t"><iframe ID="testIframe" Name="testIframe" FRAMEBORDER=0 SCROLLING=AUTO width=100%  height=390px SRC="product-category-add.html"></iframe></td>-->
    </article>
</div>
<!--_footer 作为公共模版分离出去-->
<div th:replace="pages/admin/commons/footer :: footer"></div>
<script th:src="@{/layui/layui.js}" charset="utf-8"></script>
<script type="text/javascript">

    $(function () {

        var add_record_node = '';
        $.ajax({
            url: "/childhealth/childrenHyjcmb/getChildrenHyjcmbList",
            method: "POST",
            success: function (result) {
                $.each(result.data, function (index, item) {
                    var tdCode = $("<td  class='cen'></td>").append(item.code);
                    var tdName = $("<td  class='cen'></td>").append(item.name);
                    var tdCategory = $("<td  class='cen'></td>").append(item.category);
                    if (item.isPublic == 1) {
                        var tdIsPublic = $("<td class='cen'></td>").append("<input disabled checked type='checkbox'>")
                    } else {
                        var tdIsPublic = $("<td class='cen'></td>").append("<input disabled type='checkbox'>")
                    }
                    var tdOther = $("<td></td>").append(
                        "<button uniqueId=" + item.id + " class=\"btn btn-danger radius delBtn\" type=\"button\"><i class=\"Hui-iconfont\"></i > 删除 </button>" +
                        "&nbsp;&nbsp;" +
                        "<button uniqueId=" + item.id + " class=\"btn btn-success radius updBtn\" type=\"button\"><i class=\"Hui-iconfont\"></i > 修改 </button>");
                    $("<tr></tr>").append(tdCode).append(tdName).append(tdCategory).append(tdIsPublic).append(tdOther).appendTo("#nodeInfo");
                });


                //删除
                $(".delBtn").on('click', function () {
                    var uniqueId = $(this).attr("uniqueId");
                    layer.confirm('是否确定删除: ' + $(this).parent().parent().find('td').eq(1).text() + ' ？', {
                        btn: ['删除', '取消'] //按钮
                    }, function () {
                        layer.msg('删除成功！', {icon: 1});
                        setInterval(function () {
                            window.location.href = "/childhealth/childrenHyjcmb/data-del?id=" + uniqueId;
                        }, 1000)
                    });


                })

                //修改
                $(".updBtn").on('click', function () {
                    member_add('修改', '/childhealth/childrenHyjcmb/data-upd?type=toUpd&id=' + $(this).attr("uniqueId"), '', '510')
                })

            }
        })


        //添加记录
        $("#add_record").click(function () {
            member_add('添加', '/childhealth/childrenHyjcmb/data-upd?type=toAdd&addRecordNode=' +
                add_record_node, '', '510'
            )
        })
    })

</script>
</body>
</html>
